package com.class06.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
//@Aspect
public class HelloAround {

    @Around("execution(* com.class06.service.impl.HelloService.sayHello(..))")
    public Object testHelloAround(ProceedingJoinPoint joinPoint){
        Object result = null;
       try{
           System.out.println("环绕通知的前置");
           int a = 10 / 0;
           result = joinPoint.proceed();
           System.out.println("环绕通知的返回");
            throw new RuntimeException("不能执行");
       }catch (Throwable e){
           e.printStackTrace();
           System.out.println("环绕通知的异常");
       }finally {
           System.out.println("环绕通知的后置");
       }
        return result;
    }
}
